package com.kang.servlet;

import com.alibaba.fastjson.JSON;
import com.kang.dao.impl.water_purifierDaoImpl;
import com.kang.dao.impl.water_purifierDelDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by lenovo on 2018/8/11.
 */
@WebServlet(name = "findWaterCountServlet")
public class findWaterCountServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        String json=null;
       if(request.getParameter("falg")==null){
           int count[]={water_purifierDaoImpl.MaxCount,water_purifierDaoImpl.pages};
         json= JSON.toJSONString(count);
       }else {
           int count[]={water_purifierDelDaoImpl.MaxCount,water_purifierDelDaoImpl.pages};
           json= JSON.toJSONString(count);
       }

        out.print(json);
        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
